package org.joinme.backend.util;

import java.util.HashMap;
import java.util.Map;

public class ErrorCodeMsg {
	public static Map<Integer, String> errMsg = new HashMap<Integer, String>();
	
	//1开头为系统类错误
	public static int SYSTEM_ERROR = 10000;
	public static int OPERATION_FAIL = 10001;
	public static int PARAMETER_ERROR = 10002;
	
	//2为用户类错误
	public static int USER_WECHAT_LOGIN_CODE_ERROR = 20000;
	public static int USER_WECHAT_LOGIN_FAIL = 20001;
	public static int USER_WECHAT_NOT_LOGIN = 20002;
	public static int USER_WECHAT_UPDATE_FAIL = 20003;
	public static int USER_ADMIN_LOGIN_FAIL = 20004;
	public static int USER_ADMIN_NOT_LOGIN = 20005;
	public static int USER_ADMIN_NO_AUTHORITY = 20006;
	public static int USER_NOT_LOGIN = 20007;
	
	//3为拼单类
	public static int CAR_POOLING_RECORD_START_LOCATION_EMPTY = 30000;
	public static int CAR_POOLING_RECORD_END_LOCATION_EMPTY = 30001;
	public static int CAR_POOLING_RECORD_DEPART_TIME_EMPTY = 30002;
	public static int CAR_POOLING_RECORD_ADD_ERROR = 30003;
	public static int CAR_POOLING_RECORD_COMPLETE_ERROR = 30004;
	
	//4为评价错误
	public static int COMMENT_ADD_ERROR = 40000;
	public static int COMMENT_CONTENT_EMPTY = 40001;

	//5位参与类错误
	public static int PARTICIPATE_RECORD_ADD_ERROR = 50000;
	public static int PARTICIPATE_RECORD_CANCEL_ERROR = 50001;

	//6为申请类错误
	public static int APPLICATION_RECORD_ADD_ERROR = 60000;
	public static int APPLICATION_RECORD_UPDATE_ERROR = 60001;

	//7为聊天类错误
	public static int MESSAGE_GET_ERROR = 70000;
	public static int MESSAGE_ADD_ERROR = 70001;
    
	static {
		errMsg.put(SYSTEM_ERROR, "系统忙碌");
		errMsg.put(OPERATION_FAIL, "操作失败");
		errMsg.put(PARAMETER_ERROR, "参数错误");
		
		errMsg.put(USER_WECHAT_LOGIN_CODE_ERROR, "登录错误，请检查code等相关参数");
		errMsg.put(USER_WECHAT_LOGIN_FAIL, "登录失败，请重试");
		errMsg.put(USER_WECHAT_NOT_LOGIN, "用户未登录");
		errMsg.put(USER_WECHAT_UPDATE_FAIL, "用户信息更新失败");
		errMsg.put(USER_ADMIN_LOGIN_FAIL, "登录失败，请检查用户名或密码");
		errMsg.put(USER_ADMIN_NOT_LOGIN, "用户未登录");
		errMsg.put(USER_ADMIN_NO_AUTHORITY, "用户没有权限");
		errMsg.put(USER_NOT_LOGIN, "用户未登录");
		
		errMsg.put(CAR_POOLING_RECORD_START_LOCATION_EMPTY, "出发地为空");
		errMsg.put(CAR_POOLING_RECORD_END_LOCATION_EMPTY, "终点为空");
		errMsg.put(CAR_POOLING_RECORD_DEPART_TIME_EMPTY, "出发时间为空");
		errMsg.put(CAR_POOLING_RECORD_ADD_ERROR, "添加拼单失败");
		errMsg.put(CAR_POOLING_RECORD_COMPLETE_ERROR, "拼单完成失败（非创建者不可点击完成）");
		
		errMsg.put(COMMENT_ADD_ERROR, "添加评价错误");
		errMsg.put(COMMENT_CONTENT_EMPTY, "评价内容为空");

		errMsg.put(PARTICIPATE_RECORD_ADD_ERROR, "添加参与记录出错");
		errMsg.put(PARTICIPATE_RECORD_CANCEL_ERROR, "取消参与出错");

		errMsg.put(APPLICATION_RECORD_ADD_ERROR, "添加申请记录出错");
		errMsg.put(APPLICATION_RECORD_UPDATE_ERROR, "更新申请记录出错");

		errMsg.put(MESSAGE_GET_ERROR, "查询信息出错（非拼单成员无法查询）");
		errMsg.put(MESSAGE_ADD_ERROR, "添加信息出错");
	}
	
	public static String getErrorMsg(int code){
		return errMsg.get(code);
	}
}
